<!-- 搜索栏 -->
<form nz-form [formGroup]="searchForm" class="ant-advanced-search-form">
    <div nz-row [nzGutter]="24" style="white-space: nowrap">
        <div nz-col [nzSpan]="5">
            <div nz-row>
                <nz-form-label class="search-form-label" nzFor="postName">岗位名称</nz-form-label>
                <nz-form-control class="search-form-control">
                    <input class="default-input" nz-input formControlName="postName" placeholder="输入岗位名称" />
                    <div *ngIf="submitted && fm['postName'].invalid">
                        <div *ngIf="fm['postName'].errors?.['maxlength']">名称长度不超过50</div>
                    </div>
                </nz-form-control>
            </div>
        </div>
        <div nz-col [nzSpan]="5">
            <div nz-row>
                <nz-form-label class="search-form-label" nzFor="postCode">岗位编码</nz-form-label>
                <nz-form-control class="search-form-control">
                    <input class="default-input" nz-input formControlName="postCode" placeholder="输入岗位编码" />
                    <div *ngIf="submitted && fm['postCode'].invalid">
                        <div *ngIf="fm['postCode'].errors?.['maxlength']">名称长度不超过50</div>
                    </div>
                </nz-form-control>
            </div>
        </div>
        <div nz-col [nzSpan]="5">
            <div nz-row>
                <nz-form-label class="search-form-label" nzFor="enabled">状态</nz-form-label>
                <nz-form-control class="search-form-control">
                    <nz-select class="post-enabled" name="enabled" formControlName="enabled" [nzAllowClear]="true">
                        <nz-option nzValue="true" nzLabel="正常"></nz-option>
                        <nz-option nzValue="false" nzLabel="停用"></nz-option>
                    </nz-select>
                </nz-form-control>
            </div>
        </div>
        <div nz-col [nzSpan]="9">
            <div nz-row>
                <nz-col class="search-button-col">
                    <app-search-button [search]="true" (searchEvent)="onSearch()" [reset]="true"
                        (resetEvent)="onReset()" [create]="true" (createEvent)="onCreate(editPostTitle, editPostContent)"></app-search-button>
                </nz-col>
            </div>
        </div>
    </div>
</form>

<!-- 岗位表格 -->
<nz-row style="margin-top: 4px; white-space: nowrap;">
    <nz-table #expandTable [nzData]="posts" nzTableLayout="fixed" [nzFrontPagination]="false" [nzPageIndex]="pageIndex"
        [nzPageSize]="pageSize" [nzTotal]="total" (nzQueryParams)="onPageParamChange($event)">
        <thead>
            <tr>
                <th>岗位名称</th>
                <th>岗位编码</th>
                <th>状态</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
        </thead>

        <tbody>
            <tr *ngFor="let post of posts">
                <td>{{post.postName}}</td>
                <td>{{post.postCode}}</td>
                <td>{{post.enabled}}</td>
                <td>{{post.createTime}}</td>
                <td [nzEllipsis]="true" style="overflow: hidden;" nzRight>
                    <button nz-button class="action-button normal-button" (click)="onDetail(detailTitle, detailContent, post)">详情</button>
                    <button nz-button class="action-button normal-button" (click)="onUpdate(editPostTitle, editPostContent, post)">编辑</button>
                    <button nz-button class="action-button delete-button" (click)="onDelete(post.postId)">删除</button>
                </td>
            </tr>
        </tbody>
    </nz-table>
</nz-row>

<nz-modal>
    <ng-template #editPostTitle>
        {{editTitle}}
        @if (postName != null) {
        <span style="color: rgb(55, 134, 90);">{{postName}}</span>
        }
    </ng-template>

    <ng-template #editPostContent>
        <app-add-post [modeSubject]="modeSubject" (addPostEvent)="onAddPostEvent($event)"></app-add-post>
    </ng-template>
</nz-modal>

<nz-modal>
    <ng-template #detailTitle>
        岗位详情:<span style="color: rgb(55, 134, 90);">{{postName}}</span>
    </ng-template>

    <ng-template #detailContent>
        <app-post-detail (detailEvent)="onDetailEvent($event)" [postSubject]="postSubject"></app-post-detail>
    </ng-template>
</nz-modal>